package com.htl.线程.ConcurrentModificationException;

import java.util.concurrent.CountDownLatch;

public class CountDownLatchTest {
    public static void main(String[] args) {

        /**
         *  减法计数器
         */
        CountDownLatch countDownLatch = new CountDownLatch(100);

        new Thread(()->{
            for (int i = 0; i < 100; i++) {
                System.out.println("+++++++++++Thread++++++++"+i);
                /**
                 *  countDown()方法：计数器减 1
                 */
                countDownLatch.countDown();
            }
        }).start();

        try {
            /**
             *  await()方法：计数器停止，唤醒其他线程
             */
            countDownLatch.await();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        for (int i = 0; i < 100; i++) {
            System.out.println("main-------------------------");
        }
    }
}
